package com.base.controller.pubg;

import com.base.api.pubg.IPubgDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * PUBG请求控制
 *
 * @author: junw
 * @date: 2018/5/17 13:58
 */
@RestController
@RequestMapping(value = "/pubg", produces = "application/json;charset=UTF-8")
public class PubgController {

    private IPubgDataService iPubgDataService;

    @Autowired
    public PubgController(IPubgDataService iPubgDataService) {
        this.iPubgDataService = iPubgDataService;
    }

    @PostMapping(value = "/LandingPoint")
    public String getLandingPoint(String displayWidth, String matchId){
        return iPubgDataService.getTelemetry(displayWidth, matchId).toString();
    }

    @PostMapping(value = "/PlayerPosition")
    public String getPlayerPosition(String displayWidth, String matchId, String name){
        return iPubgDataService.getPosition(displayWidth, matchId, name).toString();
    }

    @PostMapping(value = "/AllPlayerPosition")
    public String getAllPlayerPosition(String displayWidth, String matchId){
        return iPubgDataService.getAllPosition(displayWidth, matchId);
    }

    @PostMapping(value = "/DownloadData")
    public String downloadData(String serverName, int threadCount, String... names){
        return iPubgDataService.starDownloader(serverName , threadCount, names);
    }

    @PostMapping(value = "/serverlist")
    public String getserverList(){
        return iPubgDataService.getServerList().toJSONString();
    }

    @PostMapping(value = "/heartbeat")
    public String heartbeat(){
        return iPubgDataService.heartbeat().toJSONString();
    }

    @PostMapping(value = "/close")
    public String close(){
        return iPubgDataService.close();
    }

    @PostMapping(value = "/querymatch")
    public String querymatch(String name, String server, String startdate, String enddate){

        return iPubgDataService.querymatch(name, server, startdate, enddate);
    }
}
